﻿using MinoChat.Ui.Enums;
using System.Windows;

namespace MinoChat.Ui.Controls;
//自定义控件，Generic.xaml中定义了默认样式
public class IconButton : Button
{
    static IconButton()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(IconButton),
            new FrameworkPropertyMetadata(typeof(IconButton)));
    }
    #region 依赖属性(都是默认写法)
    // 图标类型枚举，由转换器转换成对应的UniCode字符串
    public static readonly DependencyProperty IconProperty =
        DependencyProperty.Register(
            nameof(Icon),
            typeof(IconType),
            typeof(IconButton),
            new PropertyMetadata(IconType.None));
    public IconType Icon
    {
        get => (IconType)GetValue(IconProperty);
        set => SetValue(IconProperty, value);
    }
    // 图标大小，默认16
    public static readonly DependencyProperty IconSizeProperty =
        DependencyProperty.Register(
            nameof(IconSize),
            typeof(double),
            typeof(IconButton),
            new PropertyMetadata(16.0));
    public double IconSize
    {
        get => (double)GetValue(IconSizeProperty);
        set => SetValue(IconSizeProperty, value);
    }
    // 图标和文本之间的间距，进而控制了边框和内容之间的距离
    public static readonly DependencyProperty SpacingProperty =
        DependencyProperty.Register(
            nameof(Spacing),
            typeof(double),
            typeof(IconButton),
            new PropertyMetadata(8.0));
    public double Spacing
    {
        get => (double)GetValue(SpacingProperty);
        set => SetValue(SpacingProperty, value);
    }

    #endregion
}